#include "AssetLoader.h"

namespace steam
{
	namespace coal
	{
		AssetLoader::AssetLoader(std::string dirPath)
		{
			m_dirPath = dirPath;
		}

		void AssetLoader::addModelLoader( ModelType type, IModelLoader* loader )
		{
			m_modelLoaderMap.insert(std::make_pair(type, loader));
		}

		void AssetLoader::removeModelLoader( ModelType type )
		{
			ModelLoaderMap::iterator it = m_modelLoaderMap.find(type);
			delete it->second;
			m_modelLoaderMap.erase(type);
		}

		IMesh* AssetLoader::loadModelFromFile(std::string filename, ModelType type)
		{
			ModelLoaderMap::iterator it = m_modelLoaderMap.find(type);
			if (it != m_modelLoaderMap.end())
			{
				std::string filePath = m_dirPath + std::string("\\") + filename;
				IModelLoader* loader = it->second;
				return loader->load(filePath);
			}
			return NULL;
		}

	}
}
